/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * httpd
 * Copyright (C) Dnyanesh Gate 2012 <dnyaneshgate@yahoo.com>
 * 
 * httpd is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * httpd is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _HTTP_H_
#define _HTTP_H_

#include <Socket.h>
#include <Singleton.h>
#include <sys/stat.h>
#include <Thread.h>
#include <fcntl.h>
#include <time.h>

extern char buffer[];

class Http : public Singleton<Http> {
	public:
		Http(){};
		~Http(){};
		int Init();
		void Start();
		void End();
	protected:
		
	private:
		ServerSocket *SERVER;
		Thread t[MAXCLIENTS];
		int noOfClients;
		void Listen();
		static void* getRequest(void *data);
		const char* getMimeType(const char* file);
		void SendHeader(int status, const char* title, const char* mime_t, int length, int i);
		void SendError(int status, const char* title, const char* text, int i);
		void SendFileData(const char *path, struct stat *statBuf, int i);
};

#endif // _HTTP_H_
